/*******************************************************************************
 * Copyright (c) 2010, 2030 www.mahao.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.ssh.dao.impl;

import javax.transaction.Transactional;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.itlaobing.ssh.dao.UsersDao;
import cn.itlaobing.ssh.entity.Users;

/** 
 * ClassName: UsersDaoImpl <br/> 
 * Function: TODO 功能描述 <br/> 
 * date: 2017年6月30日 上午11:37:00 <br/> 
 * 
 * @author Mmmmm 
 * @version  
 * @since JDK 1.8 
 */
@Repository
public class UsersDaoImpl implements UsersDao {
	@Autowired
	private SessionFactory sessionFactory;
	
	 private Session getSession()
	    {
	        //return sessionFactory.getCurrentSession();
		 return sessionFactory.openSession();
	    }

	@Override
	public Users findByUser(String name, String pass) {
		String hql="from Users where username=? and password = ?";
		Query query = getSession().createQuery(hql);
		query.setParameter(0, name);
		query.setParameter(1, pass);
		return (Users)query.uniqueResult();
	}

}
